#coding=utf8

from django.shortcuts import render_to_response,render
from ETP.model.user import User


def login(request):
    if request.method == "POST":
        loginName = request.POST.get("loginName")
        password = request.POST.get("password")
        if _checkUser(loginName,password):
            user = User.objects.get(loginName=loginName,password=password)
            return render(request,"ETP/index.html",{"user":user})

    return render(request,'ETP/login/login.html')


def _checkUser(loginName,password):
    if loginName != "" and password != "":
        try:
            user = User.objects.get(loginName=loginName,password=password)
            return True
        except:
            return False
    return False
